{extend name="public:layout" /}

{block name="title"}
	<title>{:site('siteName')}-会员中心</title>
{/block}

{block name="css"}
	<link rel="stylesheet" type="text/css" href="__STATIC__/{$theme}/css/user.css">
{/block}

{block name="content"}
	<div class="layui-main">
		<div class="user-main">
			<div class="user-left">
				{include file="public:user" index="0" /}
			</div>
			<div class="user-right">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">账户概况</li>
					</ul>
					<div class="layui-tab-content">
						<div class="user-account">
							<div class="user-info">
								<p>
									UID：<span>{:session('user.user_id')}</span>
									{if $U['agent'] gt 0}
										<button class="layui-btn layui-btn-normal layui-btn-mini layui-btn-radius agent">代理</button>
									{else /}
										<a href="{:url('index/agent/apply')}" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-radius">申请代理</a>
									{/if}
								</p>
								<p>用户名：<span>{$U.username}</span></p>
								<p>真实姓名：<span>{$U.realname}</span></p>
								<!-- <p>创客级别：<span>{$U.level}级创客</span></p> -->
							</div>
							<div class="user-bind">
								<div class="layui-progress layui-progress-big">
								  	<div class="layui-progress-bar" lay-percent="{$tag['progress']}%"></div>
								</div>
								<div class="safe">
									<span>安全等级：<i>{$tag['text']}</i></span>
									{if $tag['level'] lt 3}
										<a href="{:url('index/user/info')}">提升安全级别</a>
									{/if}
								</div>
								<div class="icon">
									<i class="layui-icon active">&#xe63b;</i>
									<i class="layui-icon {if $tag['level'] egt 2}active{/if}">&#xe609;</i>  
									<i class="layui-icon {if $tag['level'] eq 3}active{/if}">&#xe612;</i>  
								</div>
								<div class="time">
									上次登录：{:date('m/d H:i',$U['login_time'])}
								</div>
							</div>
							<div class="user-money">
								<span>账户余额</span>
								<div class="coin">
									{$currency.recharge}：<i>{$U.recharge}</i>
									{if $U['agent']}
										<a href="{:url('index/sell/orders')}" class="layui-btn layui-btn-small layui-btn-main">接单</a>
									{else /}
										<a href="{:url('index/agent/index')}" class="layui-btn layui-btn-small layui-btn-main">充值</a>
									{/if}
								</div>
								<div class="coin">
									{$currency.money}：<i>{$U.money}</i>
									<a href="{:url('index/user/withdraw')}" class="layui-btn layui-btn-small layui-btn-primary">提现</a>
									<a href="{:url('index/sell/sell')}" class="layui-btn layui-btn-small layui-btn-primary">挂售</a>
									<a href="{:url('index/user/transfer')}" style="margin-left: 5px;" class="layui-btn layui-btn-small layui-btn-danger">转账</a>
								</div>
								<div class="coin">
									{$currency.game}：<i>{$U.game}</i> &nbsp;&nbsp; {$currency.shopping}：<i>{$U.shopping}</i>
								</div>
							</div>
						</div>
						<div class="user-count">
							<div class="u-market">
								今日市场奖：<span onclick="location.href='/account/daily.html'">{$dayPrice}</span>
							</div>
							<div class="u-main">
								激活主账户：<span onclick="location.href='/account/main.html'">{$mainCount}</span>
							</div>
							<div class="u-son">
								复投账户：<span onclick="location.href='/account/son.html'">{$sonCount}</span>
							</div>
						</div>
					</div>
				</div> 
				<div class="layui-tab layui-tab-brief message">
					<ul class="layui-tab-title">
						<li class="layui-this">我的消息</li>
						<li style="float: right;"><a href="/article/list/1">更多</a></li>
					</ul>
					<div class="layui-tab-content">
						<table class="message-table">
						    <colgroup>
							    <col width="150">
							    <col>
							    <col width="150">
						    	<col width="100">
						    </colgroup>
						    <thead>
						        <tr>
						            <th>发信人</th>
						            <th>内容</th>
						            <th>时间</th>
						            <th>操作</th>
						        </tr>
						    </thead>
						    <tbody>
						    	{volist name="msgs" id="v"}
							        <tr>
							            <td>
							            	<i class="layui-icon">&#xe645;</i>
							            	{if $v['send_user_id'] eq 0}
							            	【系统消息】
							            	{else /}
							            		{:get_userinfo($v['send_user_id'])}
							            	{/if}
							            </td>
							            <td>{$v.info}</td>
							            <td>{:date('Y-m-d H:i',$v['add_time'])}</td>
							            <td><a data-mid="{$v['id']}" class="confirm-delete">删除</a></td>
							        </tr>
						        {/volist}
						    </tbody>
						</table>
						<div class="page">
							{$msgs->render()}
						</div>
					</div>
				</div> 
			</div>
		</div>
	</div>
{/block}

{block name="script"}
	<script type="text/javascript">
		layui.use(['form', 'layer'], function(){
			var $ = layui.jquery;
    		var layer = layui.layer;

    		$(".confirm-delete").click(function() {
    			var id = $(this).data('mid');
    			layer.confirm('确认删除？', {
		            btn: ['确认', '取消'],
		            icon: 3
		        }, function(index) {
		        	$.post('{:url("index/user/delMsg")}', {id: id}, function(res) {
		            	if(res.success == 1){
		            		layer.msg(res.msg, {
			                    time: 1000
			                }, function() {
			                    location.reload();
			                });
		            	}else{
		            		layer.msg(res.msg);
		            	}
		            },'json');
		            layer.close(index);
		        });
		        return false;
		    });



		});
	</script>
{/block}